<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

session_start();
if(!isset($_SESSION["Member_Info"]) || !is_object($_SESSION["Member_Info"]))return;
if($_COOKIE["Member_CKey"] != $_SESSION["Member_Info"] -> CKey)return;

$intLID = (int)$_data["LottoID"];
if(empty($intLID))$intLID = 4;
$intBT = (int)$_data["Bet_Type"];
$strTrinity = trim($_data["Trinity"]);
$intTrinNo = (int)$_data["TrinNo"];

include_once(__Member_Path."/logincheck_member_report.php");
include_once(__Language_Path."/lang_member/thesame_1.lang.php");
include_once(__Modules_Path."/ChangeTime.lib.php");
include_once(__Modules_Path."/Gamble.lib.php");
include_once(__Common_Path."/todaygame/Gamble".$intLID.".inc.php");
include_once(__Common_Path."/gambletype/GambleType".$_SESSION["Member_Info"] -> GambleType."_".$intLID.".inc.php");
if($_data["sType"] != "o")include_once(__Root_Path."/tmp/credit-".$_SESSION["Member_Info"] -> ID.".php");

include_once(__Common_Path."/CommToOddsRate_".$intLID.".inc.php");
$arrUserOPlus = $_SESSION["Member_Info"] -> UserCommToOdds[$intLID];

//是否顯示球的賠率
$isShow = true;

//取得 TodayGame 資料
//include(__Common_Path."/todaygame/TodayGame".$intLID."_".$intBT.".inc.php");

//取得樂透相關資料
$isShowScore = false;
$NowDate = date("Y-m-d");
$NowTime = date("H:i:s");

//取的 Gamble 設定資料
if(!is_array($_arrGamble)){
	$isShow = false;
	$intGTime = 0;
}else{
	list($intGID, $arrGData) = each($_arrGamble);
	
	if($arrGData["GameDate"] == $NowDate && $NowTime > $arrGData["EndGameTime"])$isShowScore = true;

	$arrGTime = split(":", $arrGData["GameTime"]);
	$arrGDate = split("-", $arrGData["GameDate"]);
	$intGTime = mktime($arrGTime[0], $arrGTime[1], $arrGTime[2], $arrGDate[1], $arrGDate[2], $arrGDate[0]) - time();
	if($arrGData["GameDate"] < $NowDate)$isShow = false;
	$EndGameTime = $arrGData["EndGameTime"];
	if($arrGData["GameDate"] == $NowDate && $EndGameTime < $NowTime)$isShow = false;

	//取得 TodayGame 資料
	switch($strTrinity){
		case "Cent":
			$strExp = "$intTrinNo%d%d";
			break;
		case "Dec":
			$strExp = "%d$intTrinNo%d";
			break;
		case "Unit":
			$strExp = "%d%d$intTrinNo";
			break;
	}
	$arrNum = array();
	for($i = 0; $i < 10; $i++){
		for($j = 0; $j < 10; $j++){
			$arrNum[] = sprintf($strExp, $i, $j);
		}
	}
	$arrTodayGame = getTodayGameDataForMultiNumber($intLID, $intGID, $intBT, join(",", $arrNum));

	if(!is_array($arrTodayGame)){
		$isShow = false;
	}
}

$isAllStopWager = true;
$intNum = 0;
if($isShow){
	foreach($arrTodayGame as $intBID => $arrB){
		//$flOddsPlus = $arrUserOPlus[$intBID][11] * $_arrChRate[$intBID][$_SESSION["Member_Info"] -> GambleType+10];

		foreach($arrB as $intNID => $Rows){

			$intApointNum = $_arrGLineNumToApointNum[$Rows["LottoID"]][$Rows["Bet_Type"]][$Rows["Number"]];
			if($intApointNum == null)$intApointNum = 0;
			$flOddsPlus = $arrUserOPlus[$intBID][$intApointNum][11] * $_arrChRate[$intBID][$intApointNum][$_SESSION["Member_Info"] -> GambleType+10];

			$strCon .= "parent.Game".$Rows["Bet_Type"]."[".$intNum."]=new Array('".$Rows["LottoID"]."','".$Rows["GambleID"]."','".$Rows["Bet_Type"]."','".$Rows["Number"]."','".$Rows["OddsID"]."','".($Rows["Odds"]+$_arrGambleType[$Rows["Bet_Type"]][$intApointNum]+$flOddsPlus)."','".$Rows["isStopBet"]."');\n";

			if($_data["sType"] != "o"){
				$arrLimit[$intNum] = $_arrMemStake[$Rows["Bet_Type"]][$Rows["GambleID"]][$Rows["Number"]];
				if(empty($arrLimit[$intNum]))$arrLimit[$intNum] = 0;
			}

			if($Rows["isStopBet"] == 0)$isAllStopWager = false;
			$intNum++;
		}  // while(list($intNID, $Rows) = each($arrB))  //

		if($_data["sType"] != "o"){
			$strLimit .= "parent.arrEveLimitUsed=new Array(".join(",", $arrLimit).");\n";
			unset($arrLimit);
		}  // if($_data["sType"] != "o") //
	}  // while(list($intBID, $arrB) = each($_arrTodayGame[$intGID])) //
}  // if($isShow) //

if($isAllStopWager)$isShow = false;
//已使用信用額度
$intUseCredit = (empty($_arrMemStake["_SUM"]))?0:$_arrMemStake["_SUM"];
$arrCheckKey = split(" ", microtime());
/*=================================================================*/
header("Cache-Control: no-store, no-cache, must-revalidate");	  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");															  // HTTP/1.0
?><script language="JavaScript">
<!--
<?php print $strCon.$strLimit;?>
parent.sType = "<?php print $_data["sType"];?>";
parent.strGameTime = "<?php print $intGTime;?>";
parent.strGameNo = "<?php print $arrGData["SerialNo"];?>";
parent.strChinaTime = "<?php print DateForm(date("Y-m-d"), date("H:i:s"), "m-d", "UToC")." ".TimeForm(date("Y-m-d"), date("H:i:s"), "H:i:s", "UToC");?>";
parent.strCheckKey1 = "<?php print $arrCheckKey[0];?>";
parent.strCheckKey2 = "<?php print $arrCheckKey[1];?>";
parent.UseCredit = <?php print $intUseCredit;?>;
<?php if($isShow){ ?>parent.Show7Star1_C();<?php } ?>
parent.strDisplay = "none";
//-->
</script>